//
//  LYouPreview.m
//  LYouSubscribeApp
//
//  Created by grx on 2018/12/17.
//  Copyright © 2018年 grx. All rights reserved.
//

#import "LYouPreview.h"

@implementation LYouPreview

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatUI];
        self.backgroundColor = [[UIColor whiteColor]colorWithAlphaComponent:0.0f];
    }
    return self;
}

-(void)creatUI{
    CGFloat safeBottem = MainWindows.safeAreaInsets.bottom;
    CGFloat hight = 0;
    if (safeBottem>0) {
        hight = 0;
    }
    self.bgTimeImageView = [UIImageView new];
    self.bgTimeImageView.userInteractionEnabled = YES;
    if (safeBottem>0) {
        self.bgTimeImageView.image = [UIImage imageNamed:@"timeBgX"];
    }else{
        self.bgTimeImageView.image = [UIImage imageNamed:@"timeBgImage"];
    }
    [self addSubview:self.bgTimeImageView];
    self.bgTimeImageView.contentMode = UIViewContentModeScaleToFill;
    [self.bgTimeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self).offset(hight);
        make.height.mas_equalTo(SCREEN_HEIGHT-hight);
    }];
    self.bgImageView = [UIImageView new];
    if (safeBottem>0) {
        self.bgImageView.image = [UIImage imageNamed:@"zhumBgX"];
    }else{
        self.bgImageView.image = [UIImage imageNamed:@"desktopBgImage"];
    }
    self.bgImageView.userInteractionEnabled = YES;
    self.bgImageView.contentMode = UIViewContentModeScaleToFill;
    [self addSubview:self.bgImageView];
    [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self).offset(hight);
        make.height.mas_equalTo(SCREEN_HEIGHT-hight);
    }];
}

-(void)setIsTime:(BOOL)isTime{
    if (isTime) {
        self.bgTimeImageView.hidden = NO;
        self.bgImageView.hidden = YES;
    }else{
        self.bgTimeImageView.hidden = YES;
        self.bgImageView.hidden = NO;
    }
}

@end
